<?php


namespace App\Annotation\Parser;


use Swoft\Annotation\Annotation\Mapping\AnnotationParser;
use Swoft\Annotation\Annotation\Parser\Parser;
use Swoft\Validator\ValidatorRegister;
use App\Annotation\Mapping\IsRequired;
/**
 * Class IsRequiredParser
 * @AnnotationParser(IsRequired::class)
 * @package App\Annotation\Parser
 */
class IsRequiredParser extends Parser
{

    /**
     * @param int $type
     * @param object $annotationObject
     * @return array
     * @throws \ReflectionException
     * @throws \Swoft\Validator\Exception\ValidatorException
     */
    public function parse(int $type, $annotationObject): array
    {
        if ($type != self::TYPE_PROPERTY) {
            return [];
        }
        //向验证器注册一个验证规则
        ValidatorRegister::registerValidatorItem($this->className, $this->propertyName, $annotationObject);
        return [];
    }
}
